var UngroupedList = Class.create(List, {
	initialize: function($super, data)
	{
		this.tag = "ungrp";
		this.id = "ungroupedlist";
		
		$super(data);
		
		document.observe('unmatchedlist:match', this.matchSelected.bindAsEventListener(this));
	},
	
	renderList: function()
	{
		this.list.update();
		
		var i = 0;
		this.data.az_indexes[this.currentPage].each(function(item) {
			if(!this.data.matched_data_lookup[item.id])
			{
				var li = Builder.node('li', {id: this.tag+'-listitem-'+item.id, className: 'row'+i, title: item.label}, item.label);
			
				i++ % 2 == 0 ? li.addClassName('odd') : li.addClassName('even');
			
				this.list.insert(li);
				
				new Draggable(li, { 
					revert: true,
					onStart: function(event){
						window.list_dragging = true;
					},
					onEnd: function(event){
						window.list_dragging = false;
						document.fire('list:drop', li);
					}.bind(this)
				});
			}
		}.bind(this));
		
		this.selectRowWithIndex(this.current_index);
	},
	
	matchSelected: function()
	{
		if(this.selected_count)
		{
			var items = new Array();
			for(var id in this.selected)
			{
				var item = this.data.itemWithID(id);
				items.push(new MatchedObject(item.label, item.id));
			}
			
			this.data.addMatches(items);
			document.fire('list:refresh', true);
		}
	},
	
	updateTitle: function()
	{
		this.titleBar.update(Builder.node('div', {}, [
			"Ungrouped "+this.currentPage.toUpperCase()+"'s ("+this.data.az_indexes[this.currentPage].length+" items)"
		]));
	},
	
	keyPress: function($super, event)
	{
		if(event.keyCode == 39 /* RIGHT */)
		{
			var objs = new Array();
			
			for(var id in this.selected)
				objs.push(this.data.itemWithID(id));
			
			document.fire('information:view', objs);
		}
		else
			$super(event);
	}
});